# from functools import reduce
#
# list1 = {
#     "A班级": [
#         {'姓名': '王帅', '成绩': 49},
#         {'姓名': '刘帅', '成绩': 20},
#         {'姓名': '孙帅', '成绩': 100},
#         {'姓名': '李帅', '成绩': 89},
#         {'姓名': '张帅', '成绩': 99},
#         {'姓名': '秦帅', '成绩': 59}
#     ],
#     "B班级": [
#         {'姓名': '王刚', '成绩': 30},
#         {'姓名': '刘刚', '成绩': 56},
#         {'姓名': '孙刚', '成绩': 73},
#         {'姓名': '李刚', '成绩': 0}],
#     "C班级": [
#         {'姓名': '王龙', '成绩': 90},
#         {'姓名': '刘龙', '成绩': 96},
#         {'姓名': '孙龙', '成绩': 93},
#         {'姓名': '李龙', '成绩': 97},
#         {'姓名': '张龙', '成绩': 98}]
# }
#
# # 1. 分别计算每个班级的总成绩
# # for i in list1:
# #     print(list1[i])
# #     # 方法 1
# #     cj = 0
# #     for j in list1[i]:
# #         cj += j["成绩"]
# #     print(i,cj)
# #     # 方法 2
# #     # print(i,reduce(lambda a,b:a+b,[j["成绩"] for j in list1[i]]))
#
#
# # 2. 把所有学生按照成绩从高到低进行排序
# stus = []
# for i in list1:
#     print(list1[i])
#     stus += list1[i]
#
#
# # print(stus)
#
# def get_keys(x):
#     return x["成绩"]
#
# print(sorted(stus, key=get_keys, reverse=True))


# def climbStairs(n):
#     if n == 1:
#         return 1
#     if n == 2:
#         return 2
#
#     return climbStairs(n - 1) + climbStairs(n - 2)
#
#
# n = 10
# total_ways = climbStairs(n)
# print("蹬到第", n, "层的方法数为:", total_ways)

#
# a = [1, 3, 4, 5, 6, 2, 3, 2, 1, 4, 2]
# k = 4
#
#
# def get_max(a, k):
#     b = sorted(a, reverse=True)
#     return b[k - 1]
#
#
# print(get_max(a, k))
# import random
#
# a = [3, 4, 1, 2, 4, 5, 7, 8, 87, 65, 43, 23, 22]
#
#
# def is_sort(a):
#     b = 0
#     for i in a:
#         if i < b:
#             return False
#         b = i
#
#     return True
#
#
# def m(a):
#     while not is_sort(a):
#         random.shuffle(a)
#
#     return a
#
#
# bb = m(a)
# print(bb)


class Stack:
    def __init__(self):
        self.lst = []

    def push(self, n: int) -> None:
        self.lst.append(n)

    def pop(self) -> int:
        if len(self.lst) == 0:
            raise IndexError("Stack is empty")
        return self.lst.pop()


z = Stack()
z.push(1)
z.push(2)
z.push(3)
print(z.pop())
print(z.pop())
print(z.pop())
